import { useState, useEffect } from "react";
import { own_columns2 } from "../utils";
import { Input, Select, Table,Pagination } from "antd";
const { Search } = Input;
const useOptions = [
  {
    value: "all",
    label: "所有",
  },
  {
    value: 0,
    label: "用户",
  },
  {
    value: 2,
    label: "管理员",
  },
];

export default function UserList({status}) {
  const [userList, setUserList] = useState([]);
  const [total,setTotal] = useState(0);
  const [limit,setLimit] = useState(10);
  const [page,setPage] = useState(1);

  useEffect(() => {
    const originData = [];
    setTotal(50)
    for (let i = 0; i < 10; i++) {
      originData.push({
        id: `04ecf011-f3ed-492b-82cb-0e4f25405728${i}`,
        birth: "1974-05-06",
        year: 10 + i,
        createdAt: "2024-05-07 08:59:27",
        startAt: "2024-05-07 08:59:27",
        endAt: "2024-05-07 08:59:27",
        state: 4,
        sex: 1,
        sNo: 20240507085104,
        pos: "颈动脉",
        name: `严忠彬${i + 1}`,
        pat_hospital: "长寿区云集镇卫生院",
        patient_sn: "CMX7-EX-2402002",
        key:`04ecf011-f3ed-492b-82cb-0e4f25405728${i}`,
      });
    }
    setUserList(originData);
  }, [status]);

  const onSearch = (value, _e, info) => console.log(info?.source, value);

  const handlePagination = (page, pageSize) => {
    setPage(page);
    setLimit(pageSize);
  }
  const onShowSizeChange = (current, pageSize) => {
    setPage(1);
    setLimit(pageSize);
  };

  return (
    <div className=" w-full h-full relative p-4">
      <div className=" flex items-center ">
        <Search
          onSearch={onSearch}
          style={{
            width: 120,
          }}
        />
        <span className=" text-custom-gray">选择角色:</span>
        <Select
          defaultValue="all"
          options={useOptions}
          style={{
            width: 120,
          }}
        />
      </div>
      <div className=" my-2">
        <Table dataSource={userList} columns={own_columns2}    pagination={false}/>;
      </div>
      <div className=" bg-white">
        <Pagination total={total} current={page} pageSize={limit} onChange={handlePagination} showSizeChanger  onShowSizeChange={onShowSizeChange} showQuickJumper />
      </div>
    </div>
  );
}
